<template>
  <div v-if="show" :class="ui.wrapper" v-bind="attrs">
    <div class="wandering-cubes">
      <div class="cube1"></div>
      <div class="cube2"></div>
    </div>
    <p :class="ui.content">加载中...</p>
  </div>
</template>

<script setup lang="ts">
  const config = {
    wrapper: '',
    content: 'text-slate-500 text-center mb-40'
  }
  const props = defineProps({
    show: {
      type: Boolean,
      default: true
    },
    class: {
      type: [String, Object, Array] as PropType<any>,
      default: undefined
    }
  })
  const { ui, attrs } = useUI('content.loading', undefined, config, toRef(props, 'class'), true)
</script>

<style>
  .wandering-cubes {
    height: 60px;
    width: 60px;
    right: 0;
    left: 0;
    z-index: 10;
    margin-right: 40px;
    display: flex;
    margin: 100px auto 30px;
    position: relative;
  }
  .cube1,
  .cube2 {
    width: 16px;
    height: 16px;
    background-color: rgb(var(--color-primary-DEFAULT));
    position: absolute;
    top: 0;
    left: 0;
    -webkit-animation: cubemove 1.8s infinite ease-in-out;
    animation: cubemove 1.8s infinite ease-in-out;
  }

  .cube2 {
    -webkit-animation-delay: -0.9s;
    animation-delay: -0.9s;
  }
  @keyframes cubemove {
    25% {
      transform: translateX(42px) rotate(-90deg) scale(0.5);
      -webkit-transform: translateX(42px) rotate(-90deg) scale(0.5);
    }

    50% {
      transform: translateX(42px) translateY(42px) rotate(-179deg);
      -webkit-transform: translateX(42px) translateY(42px) rotate(-179deg);
    }

    50.1% {
      transform: translateX(42px) translateY(42px) rotate(-180deg);
      -webkit-transform: translateX(42px) translateY(42px) rotate(-180deg);
    }

    75% {
      transform: translateX(0px) translateY(42px) rotate(-270deg) scale(0.5);
      -webkit-transform: translateX(0px) translateY(42px) rotate(-270deg) scale(0.5);
    }

    100% {
      transform: rotate(-360deg);
      -webkit-transform: rotate(-360deg);
    }
  }
</style>
